#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import wsgiref.handlers
import cgi
import gmaps
from fields import Field
from google.appengine.ext import webapp
from google.appengine.api import users
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db

class MainHandler(webapp.RequestHandler):

  def get(self):
    self.response.out.write('Hello anton!')
    
    self.response.headers['Content-Type'] = 'text/plain'
    self.response.out.write( 'Initializing\n' )
        
    field = Field()      
    field.name = "Holy Trinity"
    field.address = "180 Katimavik Road Kanata ON K2L 4A7"    
    field.lat = gmaps.location2latlong( field.address )[0] 
    field.long = gmaps.location2latlong( field.address )[1]
    
    field.put()
    
    field = Field()  
    field.name = "Bridlewood North Mini"
    field.address = "Bridlewood Drive Kanata Ontario"
    field.lat = gmaps.location2latlong( field.address )[0] 
    field.long = gmaps.location2latlong( field.address )[1]
    field.code = "w2"
    field.put()
    
    field = Field()  
    field.name = "Bridlewood South Mini"
    field.address = "Bridlewood Drive Kanata Ontario"
    field.lat = gmaps.location2latlong( field.address )[0] 
    field.long = gmaps.location2latlong( field.address )[1]
    field.code = "w3"
    field.put()
        
    field = Field()      
    field.name = "Bluegrass Park"
    field.address = "159 BLUEGRASS DR Kanata"    
    field.lat = "45.2843336"
    field.long = "-75.8610374"
    field.code ="BG"
    field.put()
        
    field = Field()  
    field.name = "Pumphouse Park"
    field.address = "170 Castlefrank Road Kanata Ontario"
    field.lat = "45.2901132"
    field.long = "-75.8799596"
    field.code = "PH"
    field.put()
        
    field = Field()  
    field.name = "Jack Charron Arena"
    field.address = "10 MCKITRICK DR Kanata"
    field.lat = "45.2939321"
    field.long = "-75.8845096"
    field.code = "JC"
    field.put()
    
    self.response.out.write( '\nDone\n' )


def main():
  application = webapp.WSGIApplication([('/', MainHandler)], debug=True)
  wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__':
  main()
